import java.util.Scanner;

public class cf973_B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            long sum = 0;
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                if (i < n - 2) sum += Math.abs(x);
                else if(i < n - 1) sum -= x;
                else System.out.println(x + sum);
            }
        }
    }
}
